import { ref } from 'vue'
import type { Ref } from 'vue'
import cloneDeep from 'lodash.clonedeep'

export function useDataReset<T>(initial: T) {
  const origin = ref(initial) as Ref<T>
  const copy = ref(cloneDeep(initial)) as Ref<T>

  const dataReset = () => {
    copy.value = cloneDeep(origin.value)
  }

  return { origin, copy, dataReset }
}
